This version of FORTH for GEOS has been adapted from the figFORTH release-1 6502 definition by:
@Nicholas J. Vrtis
5863 Pinetree S.E.
Kentwood, MI 49508
The original definition was created and supplied by:
@Forth Interest Group
P.O. Box 1105
San Carlos, CA 94070
GEOS is a copyright of
@Berkely Softworks
This version of geosFORTH is distributed as User Supported software. You may freely copy and distribute this software. The only conditions are that you cannot charge more than a nominal copy/handling fee, and you must not remove the credits. If you find the program useful and interesting, I would like a $10 support fee, or a disk of your software in exchange to the Kentwood address. I have Forth 79 standard version which runs on the native C-64 and includes floating point support and an assembler. If I get enough interest (and support) with this version, I will port that one over to GEOS also. If you send a support fee, I will send back the Forth 79 version if I ever get that converted.
As usual, this software has been tested and does not have any bugs that I know of. If you find some, please drop me a line and describe the error or problem. Without some sort of feedback I will not know what needs to be fixed.
The definitions are presented in the order of their ASCII sort. The first line of each entry shows a symbolic description of the action of the w
The definitions are presented in the order of their ASCII sort. The first line of each entry shows a symbolic description of the action of the word on the FORTH stack. The symbols indicate the order of parameters on the stack. The stack is shown in order from left to right, with three dashes (---) indicating the execution point of the word. Symbols to the left of the dashes indicate input parameters, while symbols to the right indicate output parameters. Unless otherwise noted, all references to numbers are for 16 bit signed integers. All arithemetic is implicitly 16 bit signed integer math. The symbols used are:
@addr
memory address
8 bit byte
16 bit signed integer number
16 bit unsigned integer
boolean flag (0=false, non-0=true)
boolean false flag (0)
boolean true flag (non-0)
Some fig-FORTH words have been redefined in geosFORTH. In general, the operation has not been changed, but some of the internal working have changed in order to adapt them to a GEOS environment. Additional words have been defined for source code editing and access to some of the GEOS routines. I have not added any printer support for the source code. That is left 'as an excercise for the reader'. Source code is a standard GEOS VLIR file with each VLIR record 1024 bytes long. The last byte of the record is a zero. There are no carriage control characters. Read it in, hack it up into 64 character lines and print it.
@! n addr ---
Store the 16 bit integer
at address
@addr
@!csp ---
Save the current stack position in CSP (used as part of compiler checking).
@# n1 --- n2
Generates from a number
, the next ASCII character which is placed in an output string. The result
is the quotient after division by
@base
, and is maintained for further processing. Used between
and
(See
@#> n --- addr count
Terminates numeric output conversion by dropping
, leaving the text address and character count suitable for
@type
@#s n1 --- n2
Generates ASCII text in the text output buffer by the use of
, until a zero number
results. Used between
and
@' --- addr
Used in the form
@' wwww
Leaves the parameter field address of the dictionary word
@wwww
. Executes in a colon definition to compile the address as a literal. If the word is not found, an error message is produced.
@( ---
Starts a comment. All input until the following
or a null is ignored. Executes during a colon definition to allow comments within a definition. A blank after the leading
is required.
@(.") ---
The run-time proceedure compiled by
which prints the following inline text.
@(;code) ---
The run-time proceedure compiled by
@;code
that rewrites the code field of the most recently defined word to point to the following machine code sequence.
@(+loop) n ---
The run-time proceedure compiled by
@+loop
which increments the loop index by
and tests for loop completion.
@(abort) ---
Executes after an error. This word normally executes
@abort
@(do) ---
The run-time proceedure compiled by
which moves the loop control parameters to the return stack.
@(find) addr1 addr2 --- pfa b tf
(OK)
@addr1 addr2 --- ff
(bad)
Searches the dictionary starting at the name field address
@addr2
, matching to the text at
@addr1
. Returns the parameter field address (
), the length byte of the name field (
), and a true flag (
) for a good match. If no match is found, only the false flag (
) is returned.
@(loop) ---
The run-time proceedure compiled by
@loop
which increments the loop index and tests for loop completion.
@(number) n1 addr1 --- n2 addr2
Convert ASCII text beginning at
@addr1+1
with regard to
@base
. The new value is accumulated into
being left as
@Addr2
is the address of the first unconvertable digit. Used by
@number
@* n1 n2 --- prod
Leave the signed product of the two signed numbers (
@n1*n2
@+ n1 n2 --- n3
Leave the sum of
@n1+n2
@+! n addr ---
to the value at the address.
@+- n1 n2 --- n3
Apply the sign of
to the value of
, leaving the result as
@+buf addr1 --- addr2 f
Advance the disk buffer address
@addr1
to the address of the next buffer
@addr2
. The flag
is false when
@addr2
is the buffer presently pointed to by the variable
@prev
@+loop n1 ---
(run time)
@addr n2 ---
(compile time)
Used in a colon definition in the form:
@do ... n1 +loop
At run time,
@+loop
selectively controls branching back to the corresponding
based on
, the current loop index, and the loop limit. The signed increment
is added to the index and the total is compared to the loop limit. The branch back to
occurs until the new index is equal or greater than the limit (if
>0), or until the new index is equal or less than the limit (if
<0). Upon exiting the loop, the parameters are discarded and execution continues after
@+loop
At compile time,
@+loop
compiles the run time word
@(+loop)
and the branch offset computed from
@here
to the address left on the stack by
. The value
is used for compile time error checking to ensure that the
@+loop
is within a
@+origin n --- addr
to the memory address of the origin parameter area leaving
@addr
. The parameter area is located at the start of the program area.
@, n ---
Store
into the next available dictionary location, advancing the dictionary pointer.
@- n1 n2 --- n3
Leave the difference of
@n1-n2
@-->
Continue interpretation with the next disk screen.
@-dup n --- n
(if 0)
@n --- n n
(if <>0) Duplicate
only if it is non-zero. This is usually used to copy a value just before
, to eliminate the need for an
@else
part to drop it.
@-find --- pfa b tf
(found)
@--- ff
(not found) Accepts the next text word (delimited by blanks) in the input stream to
@here
and searches
@context
and then
@current
vocabularies for a matching entry. If found, the dictionary entry's parameter field address (
), its length byte (
), and a true flag (
). Otherwise, only a flase flag (
) is left.
@-trailing addr n1 --- addr n2
Adjusts the character count
of a text string beginning at address
@-trailing addr n1 --- addr n2
Adjusts the character count
of a text string beginning at address
@addr
to suppress the output of trailing blanks or zeros (i.e. the characters at
@addr+n1
@addr+n2
are blanks or zeros).
@. n ---
Print a number from a signed 16 bit value, converted according to the numeric
@base
. A trailing blank follows.
@." ---
Used in the form:
@." wwww"
Used in a colon definition,
compiles
@(.")
and an inline string
@wwww
to transmit the text to the screen. The space after the
is necessary, and will not be included in the inline string.
Used outside a colon definition,
will immediately print the ext until the final
The maximum number of characters is 256.
@.r n1 n2 ---
Print the number
right aligned in a field whose width is
. No following blank is printed.
@/ n1 n2 --- n3
Leave the signed quotient
@n3=n1/n2
@/mod n1 n2 --- n3 n4
Leave the remainder (
) and the signed quotient of
@n1/n2
. The remainder has the sign of the dividend (
@0 1 2 3 --- n
These small numbers are used so often that it is worth while to define them as constants.
@0< n --- f
Leave a true flag if the number is less than zero (negative), otherwise leave a false flag.
@0= n --- f
Leave a true flag if the number is equal to zero, otherwise leave a false flag.
@0branch f ---
The run time procedure to conditionally branch. If
is false (0), the following signed inline value is added to the interpretive pointer to branch ahead or back. Compiled by
@until
, and
@while
@1+ n1 --- n2
Increment
by 1, leaving
@2+ n1 --- n2
Increment
by 2, leaving
@1- n1 --- n2
Decrement
by 1, leaving
Used to define a new word in FORTH, called a colon definition, using the form:
@: cccc .... ;
This creates a dictionary entry defining
@cccc
as equivalent to the following sequence of FORTH word definitionss (
) until the next
. The compiling process is done by the text interpreter as long as
@state
is non-zero. Other details are that the
@context
vocabulary is set to the
@current
vocabulary and that words with the precedence bit set are executed rather than being comipled (see
@compile
@; ---
Terminate a colon definition and stop further compilation. Compiles
@;s ---
Stop interpretation of a screen.
is also the runtime word compiled at the end
@;s ---
Stop interpretation of a screen.
is also the runtime word compiled at the end of a colon definition by (
) which returns execution to the calling word.
@< n1 n2 --- f
Leave a true flag if
is less than
; otherwise leave a false flag.
@<# ---
Setup for pictured numeric output formatting using the following form:
@<# # #s sign #>
The conversion is done on a signed number producing text at
@<builds ---
Used within a colon definition with the following form:
@: cccc <builds ....
does> .... ;
Each time
@cccc
is executed,
@<builds
defines a new word with a high level execution procedure. Executing
@cccc
in the form:
@cccc xxxx
uses
@<builds
to create a dictionary entry for
@xxxx
with a call to the
@does>
@cccc
. When
@xxxx
is later executed, it has the address of its parameter area on the stack and executes the words after
@does>
@cccc
@<builds
and
@does>
allow run time procedures written in high level rather than assembler level code.
@= n1 n2 --- f
Leave a true flag if
@n1=n2
; otherwise leave a false flag.
@> n1 n2 --- f
Leave if true flag if
@n1>n2
; otherwise leave a false flag.
@>r n ---
Remove a number from the computation (Forth) stack and place as the most accessable on the return stack. Use should be balanced with
in the
definition.
@? addr ---
Print the value contained at the address in free format (using
) according to the current base.
@?button --- f
Leave a flag indicating the current status of the mouse button. True means the button is pressed, false means the button is up. If the mouse is currently not active, a call is made to the UPDATE-MOUSE GEOS routine to get the current status of the button.
@?comp ---
Issue error message #17 if not compiling.
@?csp ---
Issue error message #20 if the current stack position differs from the value saved in
(used to make sure the stack is kept even).
@?derror n ---
is not zero, issue the error message
@DISK ERROR n
and call
@quit
. If
is zero (the normal return from a disk function),
is discarded and processing continue.
@?error f n ---
Issue error message #
, if the flag (
) is true.
@?exec ---
Issue error message #18 if not executing.
@?loading ---
Issue error message #22 if not loading.
@?mouse --- n1 n2
Leave the y coordinate (
), and the x coordinate (
) of the current mouse position. If the mouse
@?mouse --- n1 n2
Leave the y coordinate (
), and the x coordinate (
) of the current mouse position. If the mouse is not turned on (via
@mouseon
), the coordinates will be as they were the last time the mouse was active.
@?pairs n1 n2 ---
Issue error message #19 if
does not equal
. Used by figForth to indicate that compiled conditionals do not match (
@begin .... until, if ... endif
@?stack ---
Issue error message #?? if the stack is out of bounds.
@?vopen ---
Checks to see if a GEOS VLIR file is open (usually the source file). Performs no action if it is already open. If the file is not open, executes
@vopen
to open the file named in
@@ addr --- n
Leave the 16 bit contents of the address
@addr.
abort ---
Clears the stacks and enters the execution state, and return control to the terminal input device.
@abs n --- u
Leave the absolute value of
@again addr n ---
(compile)
@---
(runtime) Used in a colon definition as:
@begin .... again
At run time,
@again
forces execution to return to just after the corresponding
@begin
. The stack is unchanged. Execution will never leave this loop (unless
@r> drop
is executed one level below).
@allot n ---
Add the signed number to the dictionary pointer (
). May be used to reserve dictionary space or re-origin memory.
@and n1 n2 --- n3
Leave the bitwise logical
and
@b/buf --- n
This constant leaves the number of bytes per disk buffer (the number read from disk, excluding the screen number control bytes). Each memory buffer is
@b/buf + 2
bytes long.
@back addr ---
Calculate the backward branch offset from
@here
@addr
and compile it into the next available dictionary memory address.
@base --- addr
A user variable containing the current number base used for input and output conversion.
@begin --- addr n
(compile)
@---
(run time) Used in the colon definition as:
@begin ... until
begin ... again
begin ... while ... repeat
At run time,
@begin
marks the start of a sequence that may be repetitively executed. It serves as a return point from the corresponding
@until, again,
@repeat
. When executing
@until
, a return to
@begin
will occur if the top of the stack is false; for
@again
and
@repeat
a return to
@begin
always occurs.
At compile time,
@begin
leaves its return address (
@addr
) and
for compiler error checking.
@bl --- c
A constant that leaves the ASCII value for the "blank" character.
@blanks addr n ---
Fill and area of memory beginning at
@addr
with
"blank" characters.
@block n --- addr
Leave the memory address of the block buffer containing block
. If the block is not already in memory, it is transferred from disk to which ever buffer was least recently written. If the block occupying that buffer has been marked as updated (via
@update
), that block is first written to disk before block
is read in. See also
@buffer, update, flush
urns execution to the calling word.
@< n1 n2 --- f
Leave a true flag if
@block-read addr n1 n2 --- f
Read VLIR record number
(up to
bytes) into a buffer at address
@addr
. If there is a disk error, the standard GEOS disk error +64 is left as the flag
, otherwise a zero is returned.
@block-write addr n1 n2 --- f
Write
bytes to the VLIR record number
from buffer at
@addr
. If there is a disk error, the standard GEOS disk error +64 is left as the flag
, otherwise a zero is returned.
@branch ---
The run time word to unconditionally branch. A signed 16 bit inline offset is added to the interpretive pointer (
) to branch ahead or back.
@branch
is compiled by
@else, again, repeat
@buffer n --- addr
Obtain the next memory buffer, assigning it to block
. If the contents of the buffer are marked as updated, the buffer is written to disk before being assigned. The block is not read from the disk. The address left is the first byte within the buffer for data storage (ie. past the 2 byte block number).
@c! b addr ---
Store 8 bits at address
@addr
@c, b ---
Store 8 bits into the next available dictionary location, advancing the dictionary pointer.
@c@ addr --- b
Leave the 8 bits contents of
@addr
@cfa pfa --- cfa
Convert the parameter field address (
) of a definition to it's code field address.
@clit ---
A run time word to take the next dictionary byte and put it on the stack (this is a single byte version fo
proceeding towards higher memory. No check is made for overlapping areas.
@cold ---
The cold start word to adjust the dictionary pointer to the original value when geosForth was loaded. The word then restarts the system by calling
@abort
. This word is useful to
remove all the application programs and restart geosForth.
@compile ---
When the word containing
@compile
executes, the execution address of the word following
@compile
is copied (compiled) into the dictionary. This allows specific compilation situations to be handled in addition to simply compiling an execution address (which the interpreter already does).
@constant n ---
A defining word used in the form:
@n constant cccc
This creates the word
@cccc
, with it's parameter field containing
. When
@cccc
is later executed, it will push the value of
to the stack.
@context --- addr
A user variable containing a pointer to the vocabulary within which dictionary searches will first begin.
@cols ---
A constant containing the number of pixel columns which will fit on a screen (normally 320).
@count addr1 --- addr2 n
Leave the byte address
@addr2
and byte count
of a message text beginning at address
@addr1
. It is presumed that the first byte ad
@count addr1 --- addr2 n
Leave the byte address
@addr2
and byte count
of a message text beginning at address
@addr1
. It is presumed that the first byte ad
@addr1
contains the text byte count, and the acutal text starts with the second byte. Typically
@count
is followed by
@type
@cr ---
Set the user variable
to zero to move the text cursor to the left edge of the screen. Advance the user variable
by one text line.
check the resulting text line location against the geos bottom margin value and calls
@scroll
to scroll the screen if needed.
@create ---
A defining word used in the form:
@create cccc
Used by such words as
@code
and
@constant
to create a dictionary header for the Forth word definition. The code field contains the address of the word's parameter field.
@cccc
is created in the
@current
vocabulary.
@csp --- addr
A user variable temporarily storing the stack pointer position, for compilation error checking.
@current --- addr
A user variable containing the vocabulabulary into which new words are compiled.
@decimal ---
Set the numeric conversion
@base
for base 10 (decimal) input and output of numbers.
@definitions ---
Used in the form:
@cccc definitions
Set the
@current
vocabulary to the
@context
vocabulary. In the example, executing vocabulary name
@cccc
made it the
@context
vocabulary and executing
@definitions
made both specify the same vocabulary.
@depth --- n
A word which returns the current number of items on the Forth stack (not counting the
returned by
@depth
@desktop
This word exits geosFORTH and returns to the GEOS DeskTop.
@digit c n1 --- n2 tf
@c n1 --- ff
(bad)
Converts the ASCII character
(using the base
) to its binary equivalent
, accompanied by a true flag. If the conversion is invalid, leaves only a false flag.
@do n1 n2 ---
(run time)
@addr n ---
(compile time)
At run time,
begins a sequence with repetitive execution controlled by a loop limit
and an index. The initial index value is
removes these from the stack. Upon reaching
@loop
, the index is incremented by one. Until the new index equals or exceeds the limit, execution loops back to just after
, otherwise the loop parameters are discarded and execution
continues following the
@loop
. Both
and
are determined at run time and may be the result of other operations. Within a loop,
will copy the current value of the index to the stack. See
@i, loop, +loop, leave
. When compiling within a colon definition,
compiles
@(do)
, and leaves the following address
@addr
and
for later error checking.
@does> ---
A word which defines the run time action within a high level defining word.
@does>
alters the code field and first parameter of the new word to execute the sequence of compiled word addresses following
@does>
. Used in combination with
@<builds
. When the
@does>
part executes it begins with the address of the first parameter of the new word on the stack. This allows interpretation using this area or its contents. Typical uses include multidimensional arrays and compiler generation.
@dp --- addr
A user variable, the dictionary pointer, which contains the address of the next free memory above the dictionary. This is the value returned by
@here
, and updated by
@allot
@dpl ---
@dp --- addr
A user variable, the dictionary pointer, which contains the address of the next free memory above the dictionary. This is the value returned by
@here
, and updated by
@allot
@dpl --- addr
A user variable containing the number of digits to the right of the decimal point on integer input. It may be used to hold output column location of a decimal point in user generated formatting. The default value is -1.
@drop n ---
Discard the value currently on top of the stack.
@dup n --- n n
Duplicate the value on top of the stack.
@else addr1 n1 --- addr2 n2
(compile time)
Occurs in a colon definition in the form:
@if ... else ... endif
At run time,
@else
executes after the true part following
@if. else
forces execution to skip over the following false part and resumes exectuion after the
@endif
. It has no stack effect.
At compile time
@else
compiles
@branch
reserving a branch offset, and leaves
@addr2
for error testing.
@else
also resolves the pending forward branch from
by calculating the offset from
@addr1
@here
and storing it at
@addr1.
emit c ---
Transmit ASCII character
to the screen. The user variable
is incremented by the width of the character.
@empty-buffers ---
Mark all the block buffers as empty. Updated blocks are
written to disk.
@empty-buffers
is called as part of loading the geosForth, but is not called as part of
@cold
@enclose addr c --- addr n1 n2 n3
This is the text scanning primative used by
@word
. From the text address
@addr
and an ASCII delimiting character
@c, enclose
determines the offset (
) to the first non-delimiter character, the offset (
) to the first delimiter after the text, and the offset (
) to the first character not included.
@enclose
will not process past an ASCII 'null' ($00), treating it as an unconditional delimiter.
@end ---
This is an alias (duplicate) of
@until.
endif addr n ---
(compile time)
Occurs in a colon definition in the form:
@if ... endif
if ... else ... endif
At run time,
@endif
serves only as the destinition of a forward branch from
@else
. It marks the conclusion of the conditional structure.
At compile time,
@endif
computes the forward branch offset from
@addr
@here
and stores it at
@addr
is used to make sure the previous conditional was
@else.
erase addr n ---
Clear a regions of memory to zeros
from
@addr
for a length of
bytes.
@error n ---
Prints the error message ' ?message #
', and calls
@quit.
execute addr ---
Execute the definition whose code field address (
@addr
) is on the stack.
@expect addr n ---
Transfer character
@expect addr n ---
Transfer characters from the keyboard to
@addr
, until a
return
has been input. Only
characters will be accepted. The input string will have an ASCII 'null' added at the end.
@expect
will recognize a number of editing characters. CTRL-X will erase all input characters so you can start entering them again, the left and right cursor controls will allow you to move within the buffer.
@expect
honors the GEOS left and right margin setting. If the width of the characters being inputted exceeds the margins,
@expect
will scroll the window left and right as needed.
@fence --- addr
A user variable containing an address below which
@forget
ting is trapped. To
@forget
below this point, the user must alter the contents of
@fence
. This prevents accidentially whiping out important parts of Forth.
@fence
is initialized to the end of Forth when it is loaded.
@fill addr n b ---
Fill memory from
@addr
with
bytes of the value
first --- addr
A constant that leaves the address of the first (lowest) block buffer.
@fld --- addr
A user variable used to hold the output field width.
@flush ---
Force all updated disk buffers to be written to disk.
@desktop
calls
@flush
to make sure all buffers are written before exiting to the DeskTop.
@forget ---
Used in the form:
@forget cccc
Deletes the definition named
@cccc
from the dictionary, along with all entries physically following it. An error message will occur if the
@current
and
@context
vocabularies are not the same.
@forth ---
The name of the primary vocabulary. Execution makes
@forth
the
@context
vocabulary. Until additional user vocabularies are defined, new user definitions become a part of
@forth. forth
is immedate, so it will execute during the creation of a colon definition, to allow the selection of this vocabulary at compile time.
@get n ---
Read the screen
into memory. Unlike
@block
, this word will force a read of the screen from the disk. If the screen is currently in memory, that buffer will be reused to hold the copy being read in, but the old screen will not be written to disk.
is not updated by this word.
@here --- addr
Leave the address of the next available dictionary location.
@hex ---
Set the numeric conversion base to sixteen (hexadecimal).
@hld --- addr
A user variable that holds the adress of the latest character of text during numeric output conversion.
@hold c ---
Used between
@<# #>
to insert an ASCII character into a pictured numeric output string (e.g.
@2E hold
will place a decimal point).
@i --- n
Used within a
@do ...
to copy the current loop index to the stack.
@id. nfa ---
Print a definition's name from its name field address.
@if --- ad
@if --- addr n
(compile time)
@f ---
(run time)
Used in a colon definition in the form:
@if ... endif
if ... else ... endif
At run time,
selects execution based on the boolean flag. If
is true
(non-zero), execution continues immediately past the
. If
is false (zero), execution skips till just after the
@else
(if present) to execute the false part. After either part, execution resumes after the
@endif. else
and its false part are optional. If missing, false execution skips to just after the
@endif
At compile time
compiles
@0branch
and reserves space for an offset at
@addr. addr
and
are used later for resolution of the forward branch and error testing.
@immediate ---
Mark the most recently made definition so that when encountered at compile time, it will be executed rather than being compiled. i.e. the precedence bit in the header is set. This method allows definitions to handle unusual compiling situations rather. The user may force compilation of an immediate definition by preceeding it with
@[compile].
in --- addr
A user variable containing the byte offset within the current input text buffer (terminal or disk) from which the next text will be accepted.
@word
uses and moves the value of
interpret ---
The outer text interpreter which sequentially executes or compiles text from the input stream (terminal or disk) depending upon
@state
. If the word name cannot be found after a search of
@context
and then
@current
it is converted to a number according to the current base. If that fails, an error message echoing the input name with a " ?" will be output. Text input will be taken according to the convention for
@word.
key --- c
Leave the ASCII value of the next terminal key struck.
waits for a key to be struck.
@latest --- nfa
Leave the name field address of the top most word in the
@current
vocabulary.
@leave ---
Force termination of a
@do ...
at the next opportunity by setting the loop limit equal to the current value of the index. The index itself remains unchanged, and execution proceeds normally until
@loop
@+loop
is encountered.
@lfa pfa --- lfa
Convert the parameter field address of a dictionary definition to its link field address.
@limit --- n
A constant leaving the address just above the highest memory available for a disk buffer.
@lit --- n
Within a colon definition,
is automatically compiled before each 16 bit literal number encountered in input text. Later execution of
causes the contents of the next dictionary address to be put on the stack.
@literal n ---
(compile time)
If compiling, then compile the stack value
as a 16 bit literal.
@literal
is immediate so that it will execute during a colon definition. The intended use is in the form:
@: xxx [
calculate
@] literal ;
Compilation is suspended for the compile time calculation of a value. Compilation is resumed and
@literal
compiles this value.
@lm --- addr
A constant which returns the address of the top of memory available for FORTH to store dictionary words in. Normally this is the same as
@first
@load n ---
Begin interpretation of screen
. Loading will terminate at the end of the screen
@load n ---
Begin interpretation of screen
. Loading will terminate at the end of the screen or at
@loc-blk n --- f
Attempt to locate block
in memory. If it is
found a true flag is returned. If is is found
@prev
is updated to point to the buffer, and a false flag is returned.
@loop addr n ---
(compile time)
@---
(run time)
Occurs in a colon definition in the form:
@do ... loop
At run time,
@loop
selectively controls branching back to the corresponding
based on the loop index and limit. The loop index is incremented by one and compared to limit. The branch back to
occurs until the index equals or exceeds the limit. At that time, the parameters are discarded and
execution continues after the
@loop
At compile time,
@loop
compiles
@(loop)
and uses
@addr
to calculate an offset to
@do. n
is used for error testing.
@machine addr1 addr2 ---
Junp to the subroutine at address
@addr2
. The 6502 registers are loaded from the 4 bytes pointed to by
@addr1
. These are in the order X,Y,A,C. If C is non-zero, the carry flag will be set. If C is zero, the carry flag will be cleared before calling the subroutine. The subroutine should return via an RTS instruction. The registers and flags will be returned in the 4 bytes pointed to by
@addr1
. The full 6502 processor flags will be returned at
@addr1+3
, not just the CARRY flag. No registers need be preserved by the subroutine. Note that geosFORTH uses all the user pseudoregisters from $70-$7F, and $FB-$FE.
@max n1 n2 --- n3
Leaves the greater (
) of the two numbers.
@message n ---
Display "message
" to the screen.
@min n1 n2 --- n3
Leave the smaller of the two numbers.
@minus n1 --- n2
Leave the two's complement of
mod n1 n2 --- n3
Leave the remainder of
@n1/n2
, with the same sign as
mouseoff ---
Turn off the GEOS mouse service routine.
@mouseon n1 n2 ---
Turn on the GEOS mouse service routine, and position the mouse at X pixel coordinate
, and Y pixel coordinate
@nfa pfa --- nfa
Convert the parameter field address of a definition to its name field address.
@nop ---
A word which does nothing, but is sometimes useful because of that.
@number addr --- n
Convert a character string (with a leading count byte) at
@addr
to a signed 16 bit number, using the current numeric base. If numeric conversion is not possible, an error message will be given.
@or n1 n2 -- n3
Leave the bit wise logical or of two 16 bit values.
@out --- addr
A user variable that contains the pixel location for the next output. This variable is incremented by
@emit
and set to zero by
. You may alter this value to control display formatting.
@over n1 n2 --- n1 n2 n1
Copy the second stack value (
) to the top of the stack.
@pad --- addr
Leave the address of the text output buffer, which is a fixed offset above here.
@pfa nfa --- pfa
Convert the name field address of a compiled definition to its parameter field address.
@ppl --- n
Returns the current number of pixels per text line (based on the current font value).
@prev --- addr
A variable containing the address of the disk buffer most recently referenced.
@update
marks this buffer to be latter written to disk if the buffer is needed again.
@put n ---
Force the write of screen number
to disk. The update flag will be cleared, but the buffer will still indicate that screen
is in memory.
@query ---
Accept up to 80 characters of text (until a
RETURN
) from the keyboard. Text is returned at the address contained in
and
is set to zero.
@quit ---
Clear the return stack, stop compiliation, and return control to the keyboard. No message is given.
@r --- n
Copy the top of the return stack to the computation stack.
@r> --- n
Remove the top value from the return stack and leave it on the computation stack.
@repeat addr n ---
(compile time)
@---
(run time)
Used within a colon definition in the form:
@begin ... while ... repeat
At run time,
@repeat
forces an unconditional branch back to just after the corresponding
@begin
At compile time,
@repeat
compiles
@branch
and the offset from
@here
@addr. n
is used for error testing.
@rot n1 n2 n3 --- n2 n3 n1
Rotate the top three values on the stack, bringing the third to the top.
@row --- addr
A user variable which contains the current pixel row where the next output character will be written.
@rows --- n
A constant which returns the maximum number of pixel rows available on the screen.
@rp! ---
The word which will initialize the return stack pointer from the user variable
@rsa --- addr
A four (4) byte user variable area which can be used as a register I/O area for a call to
@machine.
@scr --- addr
A user variable which contains the current screen number being interpreted.
@scroll ---
This word will scroll up the C64 high res graphic screen one text line. The area to be scrolled is specified by the contents of the GEOS page zero areas:
@scroll ---
This word will scroll up the C64 high res graphic screen one text line. The area to be scrolled is specified by the contents of the GEOS page zero areas:
Stores and ASCII minus sign (-) just before a converted numeric output string in the text output buffer when
is negative.
is discarded, but
is maintained. Must be used between
@<# #>
@smudge ---
Used during word definition to toggle the "smudge bit" in a definitions name field. This prevents an uncompleted definition from being found during dictionary searches until compiling is completed without an error.
@source --- addr
a user variable indicating the source of the current input stream (0=keyboard, 1=disk buffer).
@sp! ---
Initialize the computational stack from
@tos.
sp@ --- addr
Returns the address of the stack position to the top of the stack as it was before
was execute.
(e.g.
@11 21 sp@ @ . . .
would type 2 21 11).
@space ---
Output an ASCII blank.
@spaces n ---
Output
ASCII blanks.
@state --- addr
A user variable containing the compilation state. A non-zero indicates compilation.
@swap n1 n2 --- n2 n1
Exchange the top two values on the stack.
@then addr n ---
(compile time)
An alias of
@endif.
tib --- addr
A user variable containing the address of the terminal input buffer.
@toggle addr b ---
Complement the contents of
@addr
by the bit pattern
tos --- n
A constant which returns the initial value to use as the top of the FORTH computational stack.
traverse addr1 n --- addr2
Move across the variable length name field of a word.
@addr1
is the address of either the length byte or the last letter of the name. If
=1, the motion is toward high memory (
@addr1
should point to the length byte): if
=-1, the motion is toward low memory.
@addr2
is the address of the other end of the name.
@type addr count ---
Output
characters from
@addr.
u* u1 u2 --- u3
Leave the unsigned number product of two unsigned numbers.
@u/ u1 u2 --- u3 u4
Leave the unsigned remainder (
) and the unsigned quotient (
) from the unsigned dividend (
) and the unsigned divisor (
@u< u1 u2 --- f
Leave a true flag if the unsigned 16 bit number
is less than the 16 bit unsigned number
ua --- n
A constant that returns the address of the start of the user variable area.
@until f ---
(run time)
@addr n ---
@until f ---
(run time)
@addr n ---
(compile time)
Used within a colon definition in the form:
@begin ... until
At run time,
@until
controls the conditional branch back to the corresponding
@begin
. If
is false, execution returns to just after
@begin
; if it is true, execution continues following the
@until
At compile time,
@until
compiles
@0branch
and and offset from
@here
@addr. n
is used for error tests.
@update ---
Mark the most recently referenced disk block (pointed to by
@prev
) as altered. The block will subsequently be written automatically to disk should its buffer be required for storage of a different block.
@use --- addr
A user variable containing the address of the block to use next, as the least recently read.
@user n ---
A defining word used in the form:
@n user cccc
This creates a user variable
@cccc
. The parameter field of
@cccc
contains
as a fixed offset relative to the user pointer register for this user variable. When
@cccc
is later executed, it places the sum of the offset and the user area base on the stack as the storage address of that particular variable. In geosForth, the user variable area is 64 bytes long. The first 48 bytes are currently used.
@variable n ---
A defining word used in the form:
@n variable cccc
This creates a definition
@cccc
with its parameter gfield initialized to
. When
@cccc
is later executed, the address of its parameter field (containing
) is left on the stack, so that a fetch or store may access this location.
@vclose --- f
Close the currently open GEOS VLIR file. The flag returned is the status flag from the GEOS close.
@vfn --- addr
A sting variable which contains the name to be used by
@vopen
for the GEOS VLIR filename. This is normally the source code file, but can contain other data. The default value is
@Forth Source
. There is room to hold up to 16 characters plus a null. The name must be null terminated.
@vgoto n --- f
Set the GEOS current VLIR record pointer to
. The flag returned is the status flag from the GEOS routine.
vlist ---
List the names of the definitions in the
@context
vocabulary. Pressing the pointer device button will stop the listing.
@voc-link --- addr
A user variable containing the address of a field in the definition of the most recently created vcoabulary. All vocabulary names are linked by these fields to allow control for
@forget
ing through multiple vocabularies.
@vocabulary ---
A defining word used in the form:
@vocabulary cccc
This creates a vocabulary definition
@cccc
. The subsequent use of
@cccc
will make it the
@context
vacabulary which is searched first by
@interpret
. The sequence
@cccc definitions
will also make
@cccc
the
@current
vocabulary into which new definitions are compiled.
@cccc
will be chained so as to include all definitions of the vocabulary in which
@cccc
is itself defined. All vocabularies ultimately chain to
@forth
. By convention, vocabulary names are to be declared
@immediate
@vopen addr --- f
This word opens the GEOS VLIR file whose name is pointed to by
@addr
. If the file does not exist, it will be created using an INFO Sector for a
@vopen addr --- f
This word opens the GEOS VLIR file whose name is pointed to by
@addr
. If the file does not exist, it will be created using an INFO Sector for a Forth Source file. The flag returned is the normal GEOS return from
@OpenRecordFile
@while f ---
(run time)
@addr1 n1 --- addr1 n1 addr2 n2
(compile time)
Used in a colon definition in the form:
@begin ... while ... repeat
At run time,
@while
selects conditional execution based on the boolean flag (
). if
is true (non-zero),
@while
continues execution of the following true part through to
@repeat
, which then branches back to
@begin
. If
is false (zero) execution skips to just after
@repeat
, exiting the structure.
At compile time,
@while
compiles
@0branch
, and leaves
@addr2
of the reserved offset. The stack values will be resolved by
@repeat.
width --- addr
A user variable containing the maximum number of letters saved in the compilation of a definition's name. It must be 1 through 31, with a default value of 31.
@word c ---
Process the next text characters from the input stream (either
or a disk buffer), until a delimiter
is found, storing the character string beginning at
@here. word
leaves the character count in the first byte, the characters, and ends with two or more blanks. Leading occurances of
are ignored.
@x ---
This is the pseudonynm for the "null" or dictionary name of one character of ASCII null (zero). It is the execution proceedure to terminate interpretation of a line of text from the terminal, or within a disk buffer, as both buffers always have a null at the end.
@xor n1 n2 --- n3
Leave the bitwise logical exclusive or of the two values.
@[ ---
Used in a colon definition in the form:
@: xxx [ ... ] ... ;
suspends compilation. The words after
are executed instead of compiled. This allows calculations or compilation execptions before resuming compilation with
. See
@literal, ].
[compile] ---
Used in a colon definition in the form:
@: xxx [compile] forth ;
[compile]
will force the compilation of an immediate word that would otherwise execute during compilation. The above example will select the forth vocabulary when
executes, rather than selecting it at compile time.
@] ---
Resulte compilation to the completion of a colon definition. See
@^cl --- n
Returns the usable number of characters of the current screen editing line (the last line has only 63 usable characters since the last character in the screen buffer must be a null).
@^ed addr n ---
This is a variation of
@expect
except that
does not empty the buffer at
@addr
before accepting input. This allows you to change the data in the buffer without retyping it.
is the number of input characters allowed. Up to
characters may be used.
pads the result out to
characters by appending spaces to what was entered.
@^el n ---
Edits line
of the current source screen.
@^es n ---
A full screen edit of source screen number
(source screen
is the same as VLIR record
will display the contents of the source screen as 16 rows of up to 64 characters on the screen and turn on the mouse. To edit one of the rows, simply position the mouse over a row and click. The mouse cursor will be replaced by a text cursor (at the beginning of the line) and you may enter data. Hitting return will put the new information back into the screen line (see
@expect
for the editing characters available). To exit
click the mouse cursor below the 16th line. Note: you can only click the mouse cursor after you are done editing a line.
@^il n ---
Insert a blank line at line
@^il n ---
Insert a blank line at line
into the current source screen. The current line
and all following lines are shifted down one line. The last line is discarded.
@^is n ---
Input the new source screen
. This word uses
@buffer
to obtain a new buffer for the source screen, fills the buffer with spaces, and then calls
for each of the 16 lines to allow you to imput source code. You will be presented with a text cursor for all 16 lines.
@^la --- addr
Calculate the address of the current editing line in the current source screen buffer.
@^ln --- addr
A user variable which hold the current source screen during editing.
@^sn" ---
Used in the form:
@^sn" cccc"
Used to change the name used for the VLIR file opened by
@vopen
. The characters up to the next
will be placed in the variable
. The space after the
@^sn"
is required and is not used as part of the name. Returns error number 6 if the name is longer than 16 characters.
@^vs n ---
View screen number
. The screen is read in from the disk if necessary, and then is displayed on the screen.
geosFORTH error message numbers
Word not found.
Stack was empty when an item was needed.
Dictionary full.
New word not unique (warning only).
Referenced screen is already in memory and should not be.